<?php
namespace app\monitor\controller;

use think\Controller;
use app\monitor\model\CategoryInfo;

class Index extends Controller
{
	
	/**
	*
	     */
	
	public function index()
	{
		debug('begin');
        $webUrls = [
		         'http://nfb.wuning.gov.cn/Category_2255/Index.aspx',
		         'http://nfb.wuning.gov.cn/Category_2256/Index.aspx',
		         'http://nfb.wuning.gov.cn/Category_2258/Index.aspx',
		         'http://nfb.wuning.gov.cn/Category_2259/Index.aspx',
		         'http://nfb.wuning.gov.cn/Category_2279/Index.aspx',
		         'http://nfb.wuning.gov.cn/Category_2281/Index.aspx'
		         ];
		
		return $this->fetch();
		foreach ($webUrls as $url) {
			$category = new CategoryInfo($url);
			echo $category->getName();
			echo $category->updateToNow();
            echo '<br>';			
		}
        echo debug('begin','end');
	}
	
	public function test($value='')
	    {
		debug('begin');
		$html = file_get_contents('http://gongyeyuan.wuning.gov.cn/Category_1164/Index.aspx');
		$htmlDom = new \HtmlParser\ParserDom($html);
		$dateDoms = $htmlDom->find('.date');
		$dates = [];
		foreach ($dateDoms as $dateDom) {
			$dates[] = $dateDom->getPlainText();
		}
		array_unshift($dates,date('Y-m-d',time()));
		
		
		
		array_walk($dates,'my_strtotime');
		dump($dates);
		echo debug('begin','end');
	}
}
